package com.lagou.myrpcprovider.service;

import com.lagou.myrpc.api.pojo.User;
import com.lagou.myrpc.api.service.IUserService;
import com.lagou.myrpcprovider.anno.RpcService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
@RpcService
public class UserServiceImpl implements IUserService {
    Map<Integer, User> userMap = new HashMap<>();

    @Override
    public User getUserById(int id) {
        if (userMap.isEmpty()) {
            userMap.put(1, new User(1, "zzz"));
            userMap.put(2, new User(2, "qqq"));
        }
        return userMap.get(id);
    }
}
